//
//  GLProgram.h
//  whfDemo
//
//  Created by 王洪飞 on 2024/2/20.
//

#import <Foundation/Foundation.h>
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>
#else
#import <OpenGL/OpenGL.h>
#import <OpenGL/gl.h>
#endif

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

NS_ASSUME_NONNULL_BEGIN

@interface GLProgram : NSObject
{
    NSMutableArray *attributes;
    NSMutableArray *uniforms;
    GLuint program,vertShader,fragShader;
}

@property(readwrite, nonatomic)BOOL initialized;
@property(readwrite, copy, nonatomic) NSString *vertexShaderLog;
@property(readwrite, copy, nonatomic) NSString *fragmentShaderLog;
@property(readwrite, copy, nonatomic) NSString *programLog;

-(id)initWithVertexShaderString:(NSString *)vShaderString
           fragmentShaderString:(NSString *)fShaderString;
-(void)addAttribute:(NSString *)attributeName;
-(GLuint)attributeIndex:(NSString *)attributeName;
-(GLuint)uniformIndex:(NSString *)uniformName;
-(BOOL)link;
-(void)use;
-(void)validate;

@end

NS_ASSUME_NONNULL_END
